﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using WebHttpApi.WebHttpApi.HttpApi;

namespace WebHttpApi
{
    /// <summary>
    /// TYComm 的摘要说明：内部指令指令请求接口
    /// </summary>
    public class TYComm : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            //text/plain方式（JSON格式字符串）：需要检查是否正确
            context.Response.ContentType = "text/plain";
            //跨域
            context.Response.AddHeader("Access-Control-Allow-Origin", "*");
            context.Response.AddHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS");
            context.Response.AddHeader("Access-Control-Allow-Headers", "Content-Type");

            #region POST参数
            //url + ?参数名1=参数值1&参数名2=参数值2
            //设备编号
            string DeviceId = "";
            DeviceId = context.Request.QueryString["DeviceId"];
            //仪表编号
            string MeterId = "";
            MeterId = context.Request.QueryString["MeterId"];

            //命令类型
            string Type = "";
            Type = context.Request.QueryString["Type"];

            //命令参数
            string CommPam = "";
            CommPam = context.Request.QueryString["CommPam"];
            #endregion

            context.Response.Write(TYComms.result(DeviceId, MeterId, Type, CommPam));
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}